﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Wordpress.Phone.Models;
using System.Collections.ObjectModel;
using Microsoft.SilverlightMediaFramework.Core.Media;
using Microsoft.SilverlightMediaFramework.Plugins.Primitives;

namespace Wordpress.Phone.ViewModels
{
    public class MovieViewModel : ViewModelBase
    {

        private ObservableCollection<PlaylistItem> _movies;
        public ObservableCollection<PlaylistItem> Movies
        {
            get
            {
                return this._movies;
            }
            set
            {
                if (this._movies != value)
                {
                    this._movies = value;
                    this.OnNotifyPropertyChanged("Movies");
                }
            }
        }
        
        private PlaylistItem _movie;
        public PlaylistItem Movie
        {
            get
            {
                return this._movie;
            }
            set
            {
                if (this._movie != value)
                {
                    this._movie = value;
                    this.OnNotifyPropertyChanged("Movie");
                }
            }
        }

        public MovieViewModel()
            : base()
        {
            this._movies = new ObservableCollection<PlaylistItem>();
            foreach (Movie m in this.data.Movies) {
                PlaylistItem item = new PlaylistItem();
                item.Title = m.Title;
                item.MediaSource = m.Source;
                item.DeliveryMethod = m.DeliveryMethod;
                this.Movies.Add(item);
            }
        }

        public void LoadMovie(int index)
        {
            this.Movie = this.Movies[index];
        }
    }
}
